package com.collectionAndMap.collection.set;

/***
 * @ClassName: Boy
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 16:28 2022/2/17
 * @version : V1.0
 */
public class Boy implements Comparable<Boy>{
    private String name;
    private Integer age;

    @Override
    public int compareTo(Boy o) {
        int n1 = this.getName().compareTo(o.getName());
        int n2 = this.getAge()-o.getAge();
        //先比姓名再比年龄
        return n1==0?n2:n1;
    }

    public String getName() {
        return name;
    }

    public Boy setName(String name) {
        this.name = name;
        return this;
    }

    public Integer getAge() {
        return age;
    }

    public Boy setAge(Integer age) {
        this.age = age;
        return this;
    }

    public Boy(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public Boy() {
    }




    @Override
    public String toString() {
        return "Boy{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
